﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DnDDB
{
    public class Mechanic
    {
        /// <summary>
        /// Rolls dice and returns the results as a list.
        /// </summary>
        /// <param name="number"></param>
        /// <param name="sides"></param>
        /// <param name="seed">Not random enough? Add some integer to help.</param>
        public static List<int> diceroll(int number, int sides, int seed)
        {
            List<int> result = new List<int>();
            for (int i = 0; i < number; i++)
            {
                Random randseed = new Random();
                Random roll = new Random(randseed.Next() + (seed / 4) + System.DateTime.Today.Millisecond);
                result.Add(roll.Next(1, sides));
            }
            return result;
        }

        public static List<int> diceroll(int number, int sides)
        {
            Random rand = new Random();
            return diceroll(number, sides, rand.Next());
        }
        /// <summary>
        /// Rolls up a stat like you really would in DnD: With 4d6 dice, dropping the lowest value.
        /// </summary>
        /// <returns></returns>
        public static int statroll()
        {
            Random rand = new Random();
            List<int> fourdsix = diceroll(4, 6);
            fourdsix.Remove(fourdsix.Min());
            return fourdsix.Sum();
        }
    }
}
